<?php
//echo class_exists('pdo');

//$d = new pdo('mysql:dbname=zgdb', 'root', '', []);
$conn = new pdo('mysql:host=localhost;port=3306;dbname=zgdb;charset=UTF8', 'root', '', []);
echo '显示所有数据库:<br>';
foreach ($conn->query('show databases') as $rows) {
    echo $rows['Database'] . '<br>';
}
echo '<br>';
echo '显示所有表:<br>';
foreach ($conn->query('show tables') as $rows) {
    echo array_shift($rows) . '<br>';
}

echo '<br>';
echo 'select * from t_user :<br>';
foreach ($conn->query('select id,name from t_user order by id desc') as $rows) {
    list($id, $name) = $rows;
    echo $id, $name, '<br>';
}